﻿<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="feeds.css" type="text/css" />
<script type="text/javascript" src="url.js"></script>
<script type="text/javascript" src="webkitxml.js"></script>
<script type="text/javascript" src="feedsStorage.js"></script>
<script type="text/javascript" src="face_config.js"></script>
<script language="javascript">
var feedsAutoDelete = new FeedsStorageAutoDelete();
var oldFeedsStorage = new FeedsStorage();
var newFeedsStorage = new FeedsStorage();
var nItemPerPage = 5;
var nLoadQzoneStatus = 0, nLoadWeiboStatus = 0;	//0未加载，1加载完成，-1加载失败
var lastWeiboId = "";   //localStorage最新微博中的id
var lastWeiboTime = ""; //localStorage最新微博中的时间
var halfYearTime = ((new Date()).getTime())/1000 - 183 * 24 * 3600;	//半年前的时间
var isShowWeibo = getParameter("showWBlog");
if(isShowWeibo == "0")isShowWeibo = false;
else isShowWeibo = true;
var weiboUser = new Object();
//找不到任何有效feeds时回调
function LoadErrorCallBack(status)	//-1为载入失败，0为没有feeds
{
	ShowErrorPanel(status);
    external.LoadErrorCallBack();
    return;
}
var bigT = ["0x800287c","0x800287d","0x800287e","0x800287f","0x8002880","0x8002881","0x8002882","0x8002883"];
//数据上报
function OnReport(id)
{
	var uin = getParameter("uin");
    var objuin = getParameter("objuin");
    var reportT;
    if(uin == objuin) reportT = bigT[id * 2];
    else reportT = bigT[id * 2 + 1];
    external.Datareport(reportT);
}
//获取g_tk
function GetG_TK()
{
    var skey = getParameter("skey");
    var hash = 5381;
    for(i = 0; i < skey.length; ++i)
    {
        var ch = skey.charCodeAt(i);
        hash += (hash << 5 & 0x7fffffff) + ch;
    }
    return hash & 0x7fffffff;
}
function HideLoadingGif()
{
    document.getElementById("loadingGif").style.display = "none";
    document.getElementById("main").style.display = "";
}
function ShowErrorPanel(status)
{
	var tips = "";
	if(status == -1)tips = "ErrFetchFeeds.png";
	else tips = "NoFeeds.png";
    document.getElementById("main").style.display = "none";
    var elem = document.getElementById("loadingGif");
    elem.innerHTML = "<img src=\"" + tips + "\"/>";
    elem.style.left = "50%";
    elem.style.top = "50%";
    elem.style.marginLeft = "-182px";
    elem.style.marginTop = "-86px";
    elem.style.display = "";
}
//加载数据
function PreLoad()
{
    //读取旧数据
    var uin = getParameter("uin");
    var objuin = getParameter("objuin");
    oldFeedsStorage.Load(uin + "_" + objuin);
    if(!isShowWeibo)oldFeedsStorage.ItemsFromWeibo = new Array();
    //先显示旧数据
    ShowAllData(0);
    if(oldFeedsStorage.ItemsFromWeibo.length > 0)
    {
        lastWeiboId = oldFeedsStorage.ItemsFromWeibo[0].id;
        lastWeiboTime = oldFeedsStorage.ItemsFromWeibo[0].abstime;
    }
}
function Load()
{ 
    //LoadXML(true);
    //取url参数
    //var uin = getParameter("uin");
    //var clientkey=getParameter("clientkey");
    PreLoad();
    
    //if(clientkey == "")
    //{
        LoadXML(null);    
    //}
    //else
    //{
        ////先访问ptlogin拿cookie
        //var ptloginUrl = "http://ptlogin2.qq.com/jump?ptlang=2052&clientuin="+ uin + "&clientkey=" + clientkey + "&u1=http%3A%2F%2Fwww.user.qzone.qq.com";
        
        //var xmlhttp = new XMLHttpRequest();
        //xmlhttp.onreadystatechange = LoadXML;
        //xmlhttp.open("GET",ptloginUrl,true);
        //xmlhttp.send(null);        
    //}
}
//加载完成
function LoadEnd()
{
	if(nLoadQzoneStatus == -1)newFeedsStorage.ItemsFromQzone = oldFeedsStorage.ItemsFromQzone;
	if(nLoadWeiboStatus == -1)newFeedsStorage.ItemsFromWeibo = oldFeedsStorage.ItemsFromWeibo;
    if(newFeedsStorage.ItemsFromQzone.length == 0 && newFeedsStorage.ItemsFromWeibo.length == 0)
    {
		if(nLoadQzoneStatus == -1 && nLoadWeiboStatus == -1)
		{
			LoadErrorCallBack(-1);
			return;
		}
        else LoadErrorCallBack(0);
    }
    var uin = getParameter("uin");
    var objuin = getParameter("objuin");
    var bDelete = false;
    try
    {
        newFeedsStorage.Save(uin + "_" + objuin);
    }
    catch(e)
    {
        bDelete = true;
        feedsAutoDelete.DeleteEnd = DeleteEndAndInsertNew;
    }
    var maxCnt = 1000;  //最多保留的记录的人数
    if(!bDelete && localStorage.length > maxCnt)bDelete = true;
    if(bDelete)
    {
        var deleteCnt = 200;    //一次性删除的条数
        if(localStorage.length > maxCnt + deleteCnt)deleteCnt = localStorage.length - maxCnt;
        setTimeout(function(){feedsAutoDelete.AutoDelete(maxCnt, deleteCnt);}, 100);
    }
}
//合并新旧数据
function MergeFeedsData(newItems, oldItems)
{
    var n = nItemPerPage - newItems.length;
    if(n <= 0)return;
    var nNew = newItems.length;
    var nOld = oldItems.length;
    var j = 0;
    for(var i = 0; i < nOld; i++)
    {
        for(;j < nNew; j++)
        {
               if(newItems[j].abstime <= oldItems[i].abstime)
               {
                    if(newItems[j].abstime != oldItems[i].abstime || newItems[j].content == oldItems[i].content)
                        break;
               }
        }
        if(j == nNew)
        {
            for(var k = i; k < nOld && n > 0; k++, n--)
            {
                newItems.push(oldItems[k]);
            }
            break;
        }
    }
}
function LoadXML(param)
{
    if(param != null && param.target.readyState != 4)return;
    //读取数据
    LoadFromQzone();
    if(isShowWeibo)
    {
		LoadFromWeibo();
	}
	else
	{
		nLoadWeiboStatus = 1;
	}
}
function LoadQzoneError(param)
{
    if(nLoadQzoneStatus != 0)return;
    nLoadQzoneStatus = -1;
    if(nLoadWeiboStatus != 0)
    {
        HideLoadingGif();
        LoadEnd();
    }
}
function LoadWeiboError(param)
{
    if(nLoadWeiboStatus != 0) return;
    nLoadWeiboStatus = -1;
    if(nLoadQzoneStatus != 0)
    {
        HideLoadingGif();
        LoadEnd();
    }
}
//for qzone
//判断来源
function JudgeFrom(item)
{ 
    //qzone return 0; weibo return 1;
    xmlNode = item.selectSingleNode("source");
    if(xmlNode == null)return -1;
    var from = xmlNode.firstChild.nodeValue;
    if(from.indexOf("QQ签名") >= 0)return 1;
    if(from.indexOf("腾讯微博") >= 0)return -1; //微博数据从微博那边取，不再使用qzone数据
    return 0;   //默认统一为QQ空间
}
function ReadFeedsItemFromQzone(node)
{
	var feedsItem = new FeedsItem();
    
    //读取appid
    var xmlNode = node.selectSingleNode("appid");
    var appid = xmlNode.firstChild.nodeValue;
    //读取typeid
    xmlNode = node.selectSingleNode("typeid");
    var typeid = xmlNode.firstChild.nodeValue;

    if(appid == "2")
    {
        feedsItem.type = 1;
    }
    else if(appid == "311")
    {
        feedsItem.type = 0;
    }
    feedsItem.from = 0;
    
    //日志标题
    xmlNode = node.selectSingleNode("ugctitle");
    if(xmlNode) feedsItem.title = xmlNode.firstChild.nodeValue;
    
    //内容url
    xmlNode = node.selectSingleNode("ugcurl");
    if(xmlNode) feedsItem.contenturl = xmlNode.firstChild.nodeValue;
    
    //图片
	xmlNode = node.selectSingleNode("picture");
    if(xmlNode)
    {
		var subItem = xmlNode.selectSingleNode("url");
		if(subItem) feedsItem.picture = subItem.firstChild.nodeValue;
    }

	//时间
    xmlNode = node.selectSingleNode("time");
    if(xmlNode) feedsItem.abstime = +xmlNode.firstChild.nodeValue; 
    
    //来源
	feedsItem.fromurl = "http://user.qzone.qq.com/" + getParameter("objuin");
 
	//内容
    xmlNode = node.selectSingleNode("orgcontent");
    if(xmlNode == null)return null;
    feedsItem.content = xmlNode.firstChild.nodeValue;
    var minlen = getParameter("minlen");
    if(minlen == "")minlen = 25;
    else minlen = parseInt(minlen);
    if(feedsItem.content.length == 0 && feedsItem.title.length == 0)return null;
    if(appid != "2" &&  feedsItem.content.length < minlen)return null;
    
    return feedsItem;
}
function LoadFromQzone()
{
	var qzonecnt = getParameter("qzonecnt");
    if(qzonecnt == "")qzonecnt = 40;
    else qzonecnt = parseInt(qzonecnt);
    
    var Offset = 0;

    var objuin = getParameter("objuin");
    var uin = getParameter("uin");
    var url = "http://rsh.qzone.qq.com/cgi-bin/feeds/feeds2_act_feeds_all_xml.cgi?store=1&mode=1&filter=2_1|2_5|311_0";
    url += "&offset=" + Offset;
    url += "&count=" + qzonecnt;
    url += "&uin=" + uin;
    if(uin == objuin)url += "&objuin=0";
    else url += "&objuin=" + objuin;
    url += "&g_tk=" + GetG_TK();
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = LoadQzoneDataAndShow;
    xmlhttp.open("GET",url, true);
    var cookie = "skey=" + getParameter("skey") + "; uin=o" + uin;
    xmlhttp.setRequestHeader("Cookie",cookie);
    xmlhttp.setRequestHeader("Cache-Control","no-cache");
    xmlhttp.send(null);
    setTimeout(function(){LoadQzoneError(xmlhttp);}, 1500);
}
var bLoadedQzone = false;
function LoadNewDataFromQzone(param)
{
    if(bLoadedQzone == true)return;
    bLoadedQzone = true;
    try
    {
        var xmlhttp = param.target;
        var xmlDoc = xmlhttp.responseXML;
        var xmlNode = xmlDoc.documentElement.selectSingleNode("result");
        if(xmlNode == null)return -1;
        xmlNode = xmlNode.selectSingleNode("data");
        if(xmlNode == null)return 0;
        var items = xmlNode.selectNodes("item");
        if(items.length == 0)return 0;
        var showSign = getParameter("sign");
        for(var i = 0; i < items.length; i++)
        {
			//判断来源
            var from = JudgeFrom(items[i]);
            if(from != 0 && !(from == 1 && showSign == "1")) continue;
            if(newFeedsStorage.ItemsFromQzone.length < nItemPerPage)
            {
                var feedsItem = ReadFeedsItemFromQzone(items[i]);		//己取消微博数据的显示
                if(feedsItem != null)
                {
					if(feedsItem.abstime < halfYearTime)break;	//半年前的过滤掉
					newFeedsStorage.AddItem(feedsItem);
				}
            }
        }
    }
    catch(e)
    {
		return -1;
	}
    return 0;
}
function LoadQzoneDataAndShow(param)
{
    if(param.target.readyState != 4)return;
    var status = LoadNewDataFromQzone(param);
	if(status == -1)nLoadQzoneStatus = -1;
	else nLoadQzoneStatus = 1;
    MergeQzoneDataAndShow();
}
function MergeQzoneDataAndShow()
{
    //if(newFeedsStorage.ItemsFromQzone.length != nItemPerPage)
    //{
        //合并数据
    //    MergeFeedsData(newFeedsStorage.ItemsFromQzone, oldFeedsStorage.ItemsFromQzone);  
    //}
    ShowAllData(1);
    if(nLoadWeiboStatus != 0)
    {
        LoadEnd();
    }
}
//end for qzone
//for weibo
function ReplaceUserNameInWeibo(str)
{
	var i = 0;
	while(i < str.length)
	{
		if(str[i++] != '@')continue;
		j = i + 1;
		while(j - i < 20)
		{
			if(j >= str.length)break;
			var c = str.charCodeAt(j);
			if(!((c >= 65 && c <= 90) || (c >= 97 && c <= 122) || (c >= 48 && c<= 57) || c == 45 || c == 95))break;
			j++;
		}
		if(j - i < 20 )
		{
			var s = str.substring(i, j).toLowerCase();
			var s2 = weiboUser[s];
			if(s2)
			{
				str = str.substring(0, i) + s2 + str.substr(j);
				j = i + s2.length;
			}
		}
		if(j < str.length)i = j;
		else break;
	}
	return str;
}
function ReadFeedsItemFromWeibo(xmlNode)
{
    var feedsItem = new FeedsItem();
    feedsItem.from = 1;

    //读取内容
    var subNode = xmlNode.selectSingleNode("content");
    if(subNode == null)return null;
    feedsItem.content = ReplaceUserNameInWeibo(subNode.firstChild.nodeValue);

    //读取id
    subNode = xmlNode.selectSingleNode("id");
    if(subNode != null && subNode.firstChild != null)
    {
        feedsItem.id = subNode.firstChild.nodeValue;
        feedsItem.contenturl = feedsItem.id;
    }
    //读取用户账号
    subNode = xmlNode.selectSingleNode("name");
    if(subNode != null && subNode.firstChild != null)
    {
        feedsItem.fromurl = subNode.firstChild.nodeValue;
    }
    //判断是否包含图片
    feedsItem.picture = "";
    subNode = xmlNode.selectSingleNode("image");
    if(subNode != null && subNode.firstChild != null)
    { 
        feedsItem.picture = subNode.firstChild.nodeValue + "/160";
    }
    if(feedsItem.picture == "")
    { 
        subNode = xmlNode.selectSingleNode("video");
        if(subNode != null)
        { 
            subNode = subNode.selectSingleNode("picurl");
            if(subNode != null && subNode.firstChild != null)
            {
                feedsItem.picture = subNode.firstChild.nodeValue;
            }
        }
    }

    subNode = xmlNode.selectSingleNode("time");
    var bEnd = true;
    if(subNode != null)
    {
        feedsItem.abstime = +subNode.firstChild.nodeValue;
    }
    return feedsItem;
}
function LoadFromWeibo()
{
    var uin = getParameter("uin");
    var objuin = getParameter("objuin");
    var url = "http://c.open.t.qq.com/api/statuses/get_user_timeline";
    var arg = "appid=800100558&app_password=4c7l7l7okA&appfrom=qq.client&version=api2.0&format=xml&wk_version=";
    arg += "&uin=" + objuin;
    //arg += "&id=" + lastWeiboId;
    //arg += "&time=" + lastWeiboTime;
    arg += "&qq_version=" + getParameter("version");
    arg += "&tokensig=" + GetG_TK(); 
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = LoadWeiboDataAndShow;
    xmlhttp.open("POST",url, true);
    var cookie = "skey=" + getParameter("skey") + "; uin=o" + uin; 
    xmlhttp.setRequestHeader("Cookie",cookie);
    xmlhttp.setRequestHeader("Content-Length",arg.length);  
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
    xmlhttp.setRequestHeader("Cache-Control","no-cache");
    xmlhttp.send(arg);
    setTimeout(function(){LoadWeiboError(xmlhttp);}, 1500);
}

function LoadNewDataFromWeibo(param)
{
	try
    {
        var xmlDoc = param.target.responseXML;
        var xmlNode = xmlDoc.documentElement.selectSingleNode("data");
        if(xmlNode == null)return -1;
        var userItem = xmlNode.selectSingleNode("user");
        if(userItem)
        {
			for(var i = 0; i < userItem.childNodes.length; ++i)
			{
				if(userItem.childNodes[i].nodeName == "#text")continue;
				weiboUser[userItem.childNodes[i].nodeName] = userItem.childNodes[i].firstChild.nodeValue;
			}
		}
        var items = xmlNode.selectNodes("info");
        if(items.length == 0)return 0;
        for(i = 0; i < items.length; i++)
        {
            if(newFeedsStorage.ItemsFromWeibo.length < nItemPerPage)
            {
                var feedsItem = ReadFeedsItemFromWeibo(items[i]);
                if(feedsItem != null)newFeedsStorage.AddItem(feedsItem);
            }
        }
    }
    catch(e)
    {
        return -1;
    }
    return 0;
}
function LoadWeiboDataAndShow(param)
{
    if(param.target.readyState != 4)return;
    var status = LoadNewDataFromWeibo(param);
    if(status == -1)nLoadWeiboStatus = -1;
    else nLoadWeiboStatus = 1;
    MergeWeiboDataAndShow();
    return 0;
}
function MergeWeiboDataAndShow()
{
	//if(newFeedsStorage.ItemsFromWeibo.length != nItemPerPage)
    //{
        //合并数据
    //    MergeFeedsData(newFeedsStorage.ItemsFromWeibo, oldFeedsStorage.ItemsFromWeibo);  
    //}
    ShowAllData(2);
    if(nLoadQzoneStatus != 0)
    {
        LoadEnd();  //加载完毕
    }
}
//end for weibo
//for show
//日期格式化
Date.prototype.format = function(format)
{
    var o = {
        "M+" : this.getMonth()+1, //month
        "d+" : this.getDate(),    //day
        "h+" : this.getHours(),   //hour
        "m+" : this.getMinutes(), //minute
        "s+" : this.getSeconds(), //second
        "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
        "S" : this.getMilliseconds() //millisecond
    }
    if(/(y+)/.test(format)) format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length));
    for(var k in o)if(new RegExp("("+ k +")").test(format))
        format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
    return format;
}
//替换表情
function ReplaceEmFromQzone(str)
{
    var nLeft = "[em]".length, nRight = "[/em]".length; 
    var left = 0, right = -nRight, preleft= 0;
    var result = "";
    var substr = "";
    
    while((left = str.indexOf("[em]", right + nRight)) >=0)
    {
        right = str.indexOf("[/em]", left + nLeft);
        if(right > 0)
        {
            substr = str.substring(left + nLeft,right);
            if(substr.length <= 7 && substr.length > 1 && substr[0] == 'e')
            {
                var i = 1;
                for(i = 1; i < substr.length; i++)
                {
                    if(substr[i] < '0' || substr[i] > '9')break;
                }
                if(i != substr.length)continue;
                result += str.substring(preleft, left);
                result += "<img src=\"http://ctc.qzonestyle.gtimg.cn/qzone/em/v" + substr + ".gif\"></img>";
                preleft = right + nRight;
            }
        }
        else
        {
            right = left;
        }
    }
    if(preleft != str.length)result += str.substring(preleft,str.length);
    return result;
}
function GetWeiboEmIndex(code)
{
	var t = "/" + code;
	var i = 0, j = 0;
	for(i = 0; i < faceConfig.length; ++i)
	{
		if(faceConfig[i][0] != "" && code.substr(0, faceConfig[i][0].length) !=  faceConfig[i][0])continue;
		for(j = 0; j < faceConfig[i][1].length; ++j)
		{
			if(t == faceConfig[i][1][j])return i;
		}
	}
	return -1;
}
function ReplaceEmoji(code)
{
	var c = escape(code);
	if(c.length == 6 && c[1] == 'u' && c[2] == 'E')
		return c.substr(2, 4).toLowerCase();
	return "";
} 
function ReplaceEmFromWeibo(str)
{
	var i = 0;
	var re;
	var replaceArray = new Array();
	while(i < str.length)
	{
		var c = str.charCodeAt(i);
		if(c > 50000 && c < 65536)
		{
			re = ReplaceEmoji(str.charAt(i));
			if(re != "")
			{
				replaceArray.push(new Array(str.charAt(i), re));
				++i;
				continue;
			}
		}
		if(str[i++] != '/')continue;
		j = i + 1;
		while(j - i < 20)
		{
			re = GetWeiboEmIndex(str.substring(i,j));
			if(re >= 0)
			{
				replaceArray.push(new Array("/" + str.substring(i,j), re));
				break;
			}
			if(j >= str.length)break;
			if("/@#\n\r\t:".indexOf(str[j]) >= 0)break;
			j++;
		}
		if(j < str.length)i = j;
		else break;
	}
	for(i = 0; i < replaceArray.length; ++i)
	{
		if(replaceArray[i][0][0] == '/')
		{
			var t = "<img src=\""+ faceConfig[replaceArray[i][1]][3] +"\"/>";
			str = str.replace(replaceArray[i][0],t);
		}
		else
		{
			var t = "<img src=\"http://mat1.gtimg.com/www/mb/images/emoji_v1/"+ replaceArray[i][1] +".png\"/>";
			str = str.replace(replaceArray[i][0],t);
		}
	}
	return str;
}
function ReplaceEm(str, from)
{
	if(from == 0)return ReplaceEmFromQzone(str);
	else return ReplaceEmFromWeibo(str);
}
//页面转码，qzone已经转码了，这里只是为了保险起见，替换"<"、">"
function ReplaceHtmlCode(str)
{
    return str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
}
function GetPtloginUrl(url)
{
	return "http://ptlogin2.qq.com/jump?clientuin=" + getParameter("uin") + "&clientkey=" + getParameter("clientkey") + "&u1=" + encodeURIComponent(url);
}
function ReplaceInvalidUrl(str)
{
	return str.replace(/"/g,"").replace(/'/g,"");
}
function ReplaceInvalidUrlStartWithHTTP(str)
{
	if(str.substr(0,4).toLowerCase() != "http")return "#";
	return ReplaceInvalidUrl(str);
}
var _isShowLoading = false;
var loadingTimerID = null;
function ClickImg(img, url)
{
	var posLeft = Math.floor(img.offsetLeft + img.width / 2);
	var posTop = Math.floor(img.offsetTop + img.height / 2);
	if(external.OpenPic(url, posLeft, posTop))
	{
		var _div = document.getElementById("imgLoadingDiv");
		posLeft -= 7;
		posTop -= 7;
		_div.style.left = posLeft + "px";
		_div.style.top = posTop+ "px";
		_div.style.display = "";
		_isShowLoading = true;
		if(loadingTimerID != null){ clearTimeout(loadingTimerID); loadingTimerID = null; }
		loadingTimerID = setTimeout(function(){ChangLoadingImg(1);}, 0);
	}
}
function OpenResult(success)
{
	loadingTimerID = null;
	_isShowLoading = false;
	var _div = document.getElementById("imgLoadingDiv");
	_div.style.display = "none";
}
function ChangLoadingImg(index)
{
	var _img = document.getElementById("imgLoading");
	_img.src = "loading/0" + index + ".png";
	if(index == 8)index = 1;
	else index++;
	if(_isShowLoading)loadingTimerID = setTimeout(function(){ChangLoadingImg(index);}, 100);
	else loadingTimerID = null;
}
function FeedsItemToHtml(item)
{
	//点击空间内容0, 点击空间来源1, 点击微博内容2， 点击微博来源3
    var html = "";
    html += "<li class=\"commendTopic\" onmouseover=\"this.className+=' liHover'\" onmouseout=\"this.className='commendTopic'\">";
    
    var contentClick = "";
    if(item.contenturl != "")
    {
        contentClick += "<a class=\"text_click\" onclick=\"";
        if(item.from == 1) contentClick += "OnReport(2);";
        else contentClick += "OnReport(0);";
        contentClick += "\" href=\"";
        var sUrl;
        if(item.from == 1) sUrl = "http://t.qq.com/p/t/" + ReplaceInvalidUrl(item.contenturl);
        else sUrl = ReplaceInvalidUrlStartWithHTTP(item.contenturl);
        contentClick += GetPtloginUrl(sUrl);
        contentClick += "\" target=\"_blank\">";
    }
    
    //日志显示标题
    if(item.title != "")
    {
        html += "<div class=\"text_title\">";
        if(contentClick != "")html += contentClick;
        html += ReplaceHtmlCode(item.title);
        if(contentClick != "")html += "</a>"
        html += "</div>";
    }
    //显示内容
    html+="<div class=\"container\">";
    if(item.picture != "")
    {
		var pictureUrl = item.picture;
		if(item.from == 1 && pictureUrl.substr(pictureUrl.length - 4) == "/160")
		{
			pictureUrl = pictureUrl.substr(0, pictureUrl.length - 4) + "/2000";
		}
		html += "<a href=\"javascript:void(0);\">"; 
        html += "<img class=\"contentPicWrap\" onclick=\"ClickImg(this, '" + pictureUrl + "');\" src=\"" + item.picture + "\"></img>";
        html += "</a>";
    }
    html += "<div class=\"text_content\">";
    if(contentClick != "")html += contentClick;
    html += ReplaceEm(ReplaceHtmlCode(item.content), item.from);
    if(contentClick != "")html += "</a>";
    html += "</div>";
    html += "</div>";
    //显示时间来源
    html += "<div class=\"text_bottom\">";
    var time = new Date();
    time.setTime(item.abstime * 1000);
    html += time.format("yyyy-MM-dd") + "&nbsp;&nbsp;&nbsp;" + time.format("hh:mm");
    if(item.from == 0)
    {
        html += "&nbsp;&nbsp;&nbsp;&nbsp;<a class=\"text_click_bottom\" target=\"_blank\" onclick=\"OnReport(1);\" href=\"" + GetPtloginUrl(ReplaceInvalidUrlStartWithHTTP(item.fromurl)) + "\">来自QQ空间</a>";
    }
    else if(item.from == 1)
    {
        html += "&nbsp;&nbsp;&nbsp;&nbsp;<a class=\"text_click_bottom\" target=\"_blank\" onclick=\"OnReport(3);\" href=\"" + GetPtloginUrl("http://t.qq.com/"+ReplaceInvalidUrl(item.fromurl)) + "\">来自腾讯微博</a>";
    }
    html += "</div>";
    html += "</li>";
    return html;
}
function ItemArrayToHtml(items)
{
    var html = "";
    for(var i = 0; i < items.length; i++)
    {
        html += FeedsItemToHtml(items[i]);
        if(i != items.length - 1)
        {
            html += "<li class=\"line1\"></li>";
            html += "<li class=\"line2\"></li>";
        }
    }
    return html;
}
function ShowDataFromItems(itemsFromQzone, itemsFromWeibo)
{
	var allItems = new Array();
	if(isShowWeibo)
	{
		var i = 0, j = 0;
		while(i < itemsFromQzone.length && j < itemsFromWeibo.length)
		{
			if(itemsFromQzone[i].abstime > itemsFromWeibo[j].abstime)
			{
				allItems.push(itemsFromQzone[i++]);
			}
			else
			{
				allItems.push(itemsFromWeibo[j++]);
			}
		}
		while(i < itemsFromQzone.length)allItems.push(itemsFromQzone[i++]);
		while(j < itemsFromWeibo.length)allItems.push(itemsFromWeibo[j++]);
	}
	else
	{
		allItems = itemsFromQzone;
	}	
    var feedsPanel = document.getElementById("feedsPanel");
    feedsPanel.innerHTML = "";
    feedsPanel.innerHTML = ItemArrayToHtml(allItems);
    var bHaveQzone = itemsFromQzone.length > 0;
	var bHaveWeibo = itemsFromWeibo.length > 0;
	if(!isShowWeibo)bHaveWeibo = false;
	if(bHaveQzone || bHaveWeibo)
	{
		feedsPanel.innerHTML += "<li class=\"line1\"></li><li class=\"line2\"></li>";
		var str = "<li class=\"bottom_tip\">";
		str += "<div>";
		str += "点击查看更多 ";
		if(bHaveQzone)
		{
			str += "<a target=\"_blank\" href=\"" + GetPtloginUrl(ReplaceInvalidUrlStartWithHTTP(itemsFromQzone[0].fromurl)) + "\">QQ空间</a>";
		}
		if(bHaveWeibo)
		{
			if(bHaveQzone)str += " 或 ";
			str += "<a target=\"_blank\" href=\"" + GetPtloginUrl("http://t.qq.com/"+ReplaceInvalidUrl(itemsFromWeibo[0].fromurl)) + "\">腾讯微博</a>";
		}
		str += " 动态";
		str += "</div>"
		str += "</li>"
		feedsPanel.innerHTML += str;
	}
}
function ShowAllData(type)//0 oldData, 1 from qzone, 2 from weibo
{
    var bHideLoading = false;
    var item1, item2;
	if(nLoadQzoneStatus == 1)item1 = newFeedsStorage.ItemsFromQzone;
    else item1 = oldFeedsStorage.ItemsFromQzone;
    if(nLoadWeiboStatus == 1)item2 = newFeedsStorage.ItemsFromWeibo;
    else item2 = oldFeedsStorage.ItemsFromWeibo;
    ShowDataFromItems(item1, item2);
    if(nLoadQzoneStatus != 0 && nLoadWeiboStatus != 0)bHideLoading = true;
    else if(item1.length > 0 || item2.length > 0)bHideLoading = true;
    if(bHideLoading)
    {
        HideLoadingGif();
    }
}
//end for show
function DeleteEndAndInsertNew()    //删除结束插入新的回调
{
    try
    {
        var objuin = getParameter("objuin");
        var uin = getParameter("uin");
        newFeedsStorage.Save(uin + "_" + objuin);
    }
    catch(e)
    {
    }
}
</script>
</head>
<body>
<div>
<div style="position:absolute;z-index:2;display:none;" id="imgLoadingDiv"><img  id="imgLoading" src="loading/01.png"></img></div>
<div id="main" style="display:none;">
<ul class="topicList" id="feedsPanel"></ul>
</div>
<div style="position: absolute;top:40%;left:35%;" id="loadingGif">
<div><img src="loadingGif.gif"/></div>
<div style="font-size:14px;" >正在加载页面，请稍候...</div>
</div>
</div>
<script language="javascript">
Load();
</script>
</body>
</html>
